<template>
  <node
    :title="config.name"
    :show-error="showError"
    :error-info="errorInfo"
    @selected="$emit('selected')"
    @delNode="$emit('delNode')"
    @insertNode2="(type) => $emit('insertNode', type)"
    placeholder="请设置触发器"
    header-bgc="#47bc82"
    header-icon="el-icon-set-up"
  />
</template>

<script setup name="TriggerNode" lang="ts">
import Node from "./Node";

const props = defineProps({
  config: {
    type: Object,
    default: () => {
      return {};
    }
  }
});

const config = ref(props.config);

const showError = ref(false);

const errorInfo = ref("");

const content = computed(() => {
  return config.value;
});

const validate = () => {
  showError.value = false;
  if (config.value.assignedUser && config.value.assignedUser.length > 0) {
    showError.value = false;
  } else {
    showError.value = true;
    errorInfo.value = "请设置触发器详情";
  }
  return !showError.value;
};
// 导出方法
defineExpose({validate})
</script>

<style scoped></style>
